package java3_29;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.Scanner;

/**
 * 5:6月的第3个星期日是父亲节，由用户输入年份，算出该年的父亲节是哪一天
 */
public class Homework5 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入年份:");
        int year = scanner.nextInt();

        LocalDate fatherDay = LocalDate.of(year, 6, 1); // 父亲节在6月，选定6月1日作为起始日期
        int sundayCount = 0; // 记录6月中星期天的个数

        while (sundayCount < 3) {
            DayOfWeek dayOfWeek = fatherDay.getDayOfWeek();
            if (dayOfWeek == DayOfWeek.SUNDAY) {
                sundayCount++;
                if (sundayCount == 3) {
                    break;
                }
            }
            fatherDay = fatherDay.plusDays(1);
        }

        System.out.println(year+"年的父亲节是"  + fatherDay);
    }
}
